home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / pctchnqs / 1991 / number2 / fonttest.cpp < prev    next >
C/C++ Source or Header  |  1991-03-08  |  1KB  |  45 lines

  1. //-------------------------------------------------------------//
  2. // File:  Fonttest.Cpp                                         //
  3. // Desc:  Example program for HpFont/Flash font drawing code   //
  4. //-------------------------------------------------------------//
  5.  
  6. #include "Fg.H"
  7. #include "HpFont.Hpp"
  8.  
  9. extern int cdecl getch( void );
  10.  
  11. int main( )
  12. {
  13.      // init for graphics
  14.      fg_init();
  15.  
  16.      // font_file is path to any valid HP Font File
  17.      char *font_file = "AMER15.HP";
  18.  
  19.      // instantiate an instance of HpFont
  20.      HpFont hpF( font_file );
  21.  
  22.      // something to draw
  23.      char *greeting = "Hello, World";
  24.  
  25.      // draw it centered on the screen
  26.      int x = ( fg.displaybox[FG_X1] + fg.displaybox[FG_X2]
  27.                - hpF.strwidth( greeting ) ) / 2;
  28.      int y = ( fg.displaybox[FG_Y1] + fg.displaybox[FG_Y2]
  29.                - hpF.strheight( greeting ) ) / 2;
  30.  
  31.      // use color white
  32.      int clr = fg.nsimulcolor - 1;
  33.  
  34.      // and draw string greeting
  35.      hpF.drawstr( x, y, clr, greeting );
  36.  
  37.      // wait for a keypress
  38.      getch();
  39.  
  40.      // terminate graphics mode
  41.      fg_term();
  42.  
  43.      return 0;
  44. }
  45.